package com.qubuyer.repository

import com.qubuyer.core.ext.toJson
import com.qubuyer.core.http.Api
import com.qubuyer.repository.services.ApiService
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody
import org.junit.Assert.assertEquals
import org.junit.Test

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)

        GlobalScope.launch {

            val response = Api.getInstance()
                    .create(ApiService::class.java)
                    .login(mapOf(Pair("username", "18206060282"),Pair("password", "123456")).toJson().toRequestBody("application/json; charset=UTF-8".toMediaTypeOrNull()))
            response.data
        }
    }
}